
/** 
 * SQL 执行语句模块
 */
const userQueries = {
  // 查询用户名
  SELECT_USER_BY_USERNAME: 'SELECT * FROM ev_user WHERE username=?',
  // 插入新用户
  INSERT_USER: 'INSERT INTO ev_user SET ?',
  // 查询用户信息
  SELECT_USER_INFO: 'SELECT id, username, nickname, email, user_pic FROM ev_user WHERE id=?',
  // 更新用户信息
  UPDATE_USER_INFO: 'UPDATE ev_user SET ? WHERE id=?',
  // 根据id查询用户
  SELECT_USER_BY_ID: 'SELECT * FROM ev_user WHERE id=?',
  // 更新用户密码
  UPDATE_USER_PASSWORD: 'UPDATE ev_user SET password=? WHERE id=?',
  // 更新用户头像
  UPDATE_USER_AVATAR: 'UPDATE ev_user SET user_pic=? WHERE id=?',
  // 根据id删除用户
  DELETE_USER_BY_ID: 'DELETE FROM ev_user WHERE id=?',
  // 根据分类的状态，获取所有未被删除的分类列表数据
  SELECT_ARTICLE_CATEGORIES: 'SELECT * FROM ev_article_cate WHERE is_delete=0 ORDER BY id ASC',
  // 查询分类名称和分类别名
  SELECT_CATEGORY_BY_NAME_OR_ALIAS: 'SELECT * FROM ev_article_cate WHERE name=? OR alias=?',
  // 新增文章分类
  INSERT_ARTICLE_CATEGORY: 'INSERT INTO ev_article_cate SET ?',
  // 根据id删除文章分类
  DELETE_ARTICLE_CATEGORY_BY_ID: 'UPDATE ev_article_cate SET is_delete=1 WHERE id=?',
  // 根据id获取文章分类
  SELECT_ARTICLE_CATEGORY_BY_ID: 'SELECT * FROM ev_article_cate WHERE id=?',
  // 根据 分类名称 与 分类别名 查重
  SELECT_CATEGORY_BY_NAME_OR_ALIAS_EXCLUDING_ID: 'SELECT * FROM ev_article_cate WHERE Id<>? AND (name=? OR alias=?)',
  // 根据id更新文章分类
  UPDATE_ARTICLE_CATEGORY_BY_ID: 'UPDATE ev_article_cate SET ? WHERE Id=?',
  // 发布新文章
  INSERT_ARTICLE: 'INSERT INTO ev_articles SET ?',
  // 获取文章的 is_delete 值
  SELECT_ARTICLE_IS_DELETED_STATUS: 'SELECT is_delete FROM ev_articles WHERE id = ?',
  // 根据文章 Id 删除文章
  UPDATE_ARTICLE_BY_IS_DELETE: 'UPDATE ev_articles SET is_delete=1 WHERE Id = ?',
  // 根据 Id 获取文章详情
  SELECT_ARTICLE_BY_ID: 'SELECT * FROM ev_articles WHERE Id = ?',
  // 更新文章信息
  UPDATE_ARTICLE_BY_ID: 'UPDATE ev_articles SET ? WHERE Id = ?',
}

module.exports = userQueries